<template>
  <section class="incometax-detail">
    <section class="data-content">
      <h5 class="content-title">客户基础信息</h5>
      <div class="info-wrap">
          <el-row>
            <el-col :span="5"><div class="info-item iconfont icon-name"> 公司名称:</div></el-col>
            <el-col :span="10"><span class="info-item" >{{ cName }}</span></el-col>
        </el-row>
      </div>
    </section>
    <div class="data-content">
      <!-- <div class="btns-content">
        <el-button @click="save" icon="el-icon-document-checked" type="primary">
          保存
        </el-button>
      </div> -->
      <h5 class="content-title">数据信息-系统自动生成数据 <el-button style="margin-left:10px;" type="small"  @click="back" >保存并返回</el-button></h5>
      <el-table :data="tableData" tooltip-effect="dark" size="mini" border>
        <el-table-column
          prop="incomeValue"
          label="本期收入"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              align="center"
              v-model="scope.row.incomeValue"
              type="number"
              @input.native="onInput"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop="costValue"
          label="本期成本"
          align="center"
        >
          <template slot-scope="scope">
            <el-input
              align="center"
              v-model="scope.row.costValue"
              type="number"
              @input.native="onInput"
            ></el-input>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </section>
</template>


<script>
export default {
  data() {
    return {
      tableData: [],
      cName: '',
      bizId: this.$route.query.bizId,
    };
  },

  components: {},
  created() {
    console.log(this)

    this.cName = this.$route.query.cName
    this.loadData();
  },
  methods: {
    save() {
      const { tableData } = this;
      this.$http
        .post("/incomeTax/saveIncomeBusinessMsg", {
          ...tableData[0],
          bizId: this.bizId
        })
        .then((res) => {});
    },
    onInput(e) {
      clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.save();
      }, 600);
    },
    loadData() {
      this.$http
        .get("/incomeTax/getIncomeBusinessMsg", {
          params: {
            bizId: this.bizId,
          },
        })
        .then((res) => {
          const {code, data} = res;

          if(code != 0) return;
          this.tableData.push(data);
        }).catch(error => {
        })
    },
    back(){
      this.$router.back();
    }
  },
};
</script>
<style lang="less" scoped>
.incometax-detail {
  padding: 0 10px;
}
.header-item {
  font-size: 14px;
  color: #333;
}
.data-content {
  margin-top: 20px;
  padding: 20px 20px 40px;
  background: #fff;
  box-sizing: border-box;
  .content-title{
    margin: -20px -20px 20px -20px;
    font-size: 16px;
    height: 44px;
    line-height: 44px;
    border-left: 4px solid #1890ff;
    border-bottom: 1px solid #eee;
    padding-left: 10px;
  }
  .content-title-two{
    margin: 20px -20px 20px -20px;
    font-size: 16px;
    height: 44px;
    line-height: 44px;
    border-left: 4px solid #1890ff;
    border-bottom: 1px solid #eee;
    padding-left: 10px;
    .title-desc{
      margin-left: 5px;
      font-size: 12px;
      font-weight: normal;
    }
  }
}
.btns-content {
  margin-bottom: 30px;
}
</style>